<template>
  <div class="rightBodyContent">
    <div class="rightBodyContent-in">
      <el-button size="small" class="mb-10" @click="InitFn()" v-if="cornerList.length">刷新当前数据</el-button>
      <div class="corner-data" v-if="cornerList.length">
        <div class="corner-data-list" v-for="item in cornerList" :key="item.id">
          <div class="corner-data-list-top-t">
            <div class="corner-data-list-img">
              <el-image :src="item.pic">
              </el-image>
            </div>
            <div class="corner-data-list-right">
              <div class="corner-data-list-right-line">
                <div class="corner-data-list-right-line-l">
                  <span>名称：</span>{{ item.name }}
                </div>
                <div class="corner-data-list-right-line-l">
                  <span>达标时长：</span>{{ item.time }}分钟
                </div>
                <div class="corner-data-list-right-line-l">
                  <span>创建时间：</span>{{ item.create_time }}
                </div>
              </div>
              <div class="corner-data-list-right-line">
                <div class="corner-data-list-right-line-l">
                  <span>预约人次：</span><i>{{ item.apply_number || 0 }}</i>
                </div>
                <div class="corner-data-list-right-line-l">
                  <span>参与人次：</span><i>{{ item.in_number || 0 }}</i>
                </div>
                <div class="corner-data-list-right-line-l">
                  <span>达标人次：</span><i>{{ item.complete_number || 0 }}</i>
                </div>
              </div>
            </div>
          </div>
          <div class="corner-data-list-top-b">
            <div class="corner-data-list-right-line-l" v-for="className in item.section"
                 @click="showCorner(item,className)">
              <i>{{ className.number }}</i><span>{{ className.section_name }}评价人次</span>
            </div>
          </div>
        </div>
      </div>
      <div v-else class="cornernot">
        <i class="iconfont iconwodewenzhang"></i>
        暂无区角统计记录
        <el-button size="small" class="mt-30" @click="InitFn()">刷新当前记录</el-button>
      </div>
    </div>
    <sectionPointList :visible.sync="dialogVisible" :cornerData="cornerData"
                      :sectionData="sectionData"></sectionPointList>
  </div>
</template>

<script>
import {cornerBrandIndex} from "@/api/admin/corner";
import sectionPointList from "./components/sectionPointList";

export default {
  components: {sectionPointList},
  data() {
    return {
      dialogVisible: false,
      sectionData: null,
      cornerData: null,
      cornerList: []
    }
  },
  created() {
    this.InitFn()
  },
  methods: {
    // 初始化
    InitFn() {
      cornerBrandIndex().then(res => {
        console.log('res:', res)
        for (let item of res.list) {
          item.create_time = item.create_time.split(' ')[0]
        }
        this.cornerList = res.list
      })
    },
    showCorner(item, classOption) {
      if(classOption.number){
        this.sectionData = classOption
        this.cornerData = item
        this.dialogVisible = true
      }else{
        this.$message.warning('没有可查看的记录');
      }
    },
    // 初始化
    async InitPicFn() {
      let data = await this.$post('', option);
      console.log('区角采集：', data)
    },
  },
  mounted() {
  }
}
</script>
<style>
.corner-data {
  overflow: hidden;
}

.corner-data-list {
  float: left;
  border: 1px solid #ddd;
  box-shadow: 0 2px 2px #ddd;
  border-radius: 5px;
  margin-right: 10px;
  margin-bottom: 10px;
  display: flex;
  padding: 10px 5px;
  cursor: pointer;
  flex-direction: column;
}

.corner-data-list:hover {
  border: 1px solid rgba(37, 132, 245, .2);
  background: rgba(37, 132, 245, .2);
  box-shadow: 0 2px 2px rgba(37, 132, 245, .2);
}

.corner-data-list-img {
  margin-right: 5px;
}

.corner-data-list-top-t {
  display: flex;
}

.corner-data-list-top-b {
  display: flex;
  margin-top: 10px;
  border-top: 1px solid #eee;
  padding-top: 10px;
}

.corner-data-list-top-b .corner-data-list-right-line-l {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #eee;
}

.corner-data-list-top-b .corner-data-list-right-line-l:last-child {
  border: none;
}

.corner-data-list-top-b .corner-data-list-right-line-l i {
  font-size: 18px;
  color: #006dcd;
  font-weight: bold;
  font-style: normal;
}


.corner-data-list-right {
  display: flex;
}

.corner-data-list-right-line:first-child {
  width: 160px;
}

.corner-data-list-right-line {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

.corner-data-list-right-line:nth-child(2) {
  width: 110px;
}

.corner-data-list-right-line:nth-child(3) {
  width: 130px;
}

.corner-data-list-right-line-l {
  display: flex;
  align-items: center;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.corner-data-list-right .corner-data-list-right-line-l span {
  color: #999;
  font-size: 13px;
}
.corner-data-list-right .corner-data-list-right-line-l i{
  font-style: normal;
}
.cornernot {
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  color: #777;
}

.cornernot i {
  font-size: 60px;
  color: #999;
  margin-bottom: 10px;
}
</style>
